BINFILE := $(IPL_BIM) $(START_HEAD_BIN) kernel.sys
SYSTEM :=system
L_OBJS  := 
K_OBJS	:= bootpack.o FuncTools.o

QEMU_FLAGS 	+= #-no-reboot -d in_asm

BIN: $(BINFILE)

%.bin:%.asm
	$(NASM) $< -o $@ -l $(subst .asm,.lst,$<)

%.o:%.asm
	$(NASM) -f elf $^ -o $@

%.o:%.c
	$(CC) $(CFLAGS) -c $< -o $@

kernel.sys: ${K_OBJS} 
	$(LD) -m elf_i386  --oformat binary -o kernel.sys -T kernel.lds $^

${SYSTEM}.bin : $(START_HEAD_BIN) kernel.sys
	cat $^ > $@

${SYSOS_NAME}.img : $(IPL_BIM) ${SYSTEM}.bin
	mformat -f 1440 -C -B $(IPL_BIM) -i $@ ::
	mcopy -i $@ ${SYSTEM}.bin ::

mkimg :
	make ${SYSOS_NAME}.img
	mv ${SYSOS_NAME}.img ../

run:
	qemu-system-i386 -fda $(SYSOS_IMG) $(QEMU_FLAGS)
	
move:
	mv $(SYSOS_IMG) $(MOVE_PATH)

clean:
	rm -rf $(BINFILE) ${K_OBJS} *.lst *.o *.bin

create_img:
	dd if=/dev/zero  of=$(SYSOS_IMG)  bs=512 count=2880
	sync

delete_img:
	rm -rf $(SYSOS_IMG)
